<?php
	$dir = '/images/products/s_img/';
	$root = sfConfig::get('sf_web_dir');	
?>
<form id="search_form" action="" method="post">
	<div id="products_search_bar">
		<div class="row">
			<span><?php echo __('关键字'); ?></span>
			<input id="ed_keywords" name="ed_keywords" type="text" value="<?php if ($ed_keywords != '') echo $ed_keywords; ?>" />
			<span><?php echo __('价格'); ?></span>
			<select id="ed_price_range" name="ed_price_range" >
				<option value=""><?php echo '-'.__('所有').'-'; ?></option>
				<option value="-1500" <?php if ($ed_price_range == '-1500') echo 'selected="selected" '; ?>>&nbsp;-1500</option>
				<option value="1500-4000" <?php if ($ed_price_range == '1500-4000') echo 'selected="selected" '; ?>>1500-4000</option>
				<option value="4000-" <?php if ($ed_price_range == '4000-') echo 'selected="selected" '; ?>>4000-&nbsp;</option>
			</select>		
			<span><?php echo __('类型'); ?></span>
			<select id="ed_type" name="ed_type" >
				<option value=""><?php echo '-'.__('所有').'-'; ?></option>
				<option value="1" <?php if ($ed_type == '1') echo 'selected="selected" ';?>><?php echo __('电子管'); ?></option>
				<option value="2" <?php if ($ed_type == '2') echo 'selected="selected" ';?>><?php echo __('晶体管'); ?></option>
			</select>
			<span><?php echo __('特性'); ?></span>
			<select id="ed_remarks" name="ed_remarks" >
				<option value=""><?php echo '-'.__('所有').'-'; ?></option>
				<option value="1" <?php if ($ed_remarks == '1') echo 'selected="selected" '; ?>><?php echo __('人声'); ?></option>
				<option value="2" <?php if ($ed_remarks == '2') echo 'selected="selected" '; ?>><?php echo __('乐器'); ?></option>
			</select>			
		</div>
		<div class="row">
			<span><?php echo __('系列'); ?></span>
			<select name="ed_series">
				<option value=""><?php echo '-'.__('所有').'-'; ?></option>
				<option value="S-" <?php if ($ed_series == 'S-') echo 'selected="selected" '; ?>>S-</option>
				<option value="Z-" <?php if ($ed_series == 'Z-') echo 'selected="selected" '; ?>>Z-</option>
				<option value="F-" <?php if ($ed_series == 'F-') echo 'selected="selected" '; ?>>F-</option>
				<option value="ED1-" <?php if ($ed_series == 'ED1-') echo 'selected="selected" '; ?>>ED1-</option>
				<option value="ED2-" <?php if ($ed_series == 'ED2-') echo 'selected="selected" '; ?>>ED2-</option>
				<option value="ED3-" <?php if ($ed_series == 'ED3-') echo 'selected="selected" '; ?>>ED3-</option>
			</select>
		</div>
		<div class="row">
			<input type="submit" id="search_submit" value="<?php echo __('搜索'); ?>" />
		</div>	
	</div>
	<div id="product_page">		
		<div class="page">
			<?php echo __('当前结果').'&nbsp;<b>'.$pager_params['begin_index'].'-'.$pager_params['end_index'].'</b>&nbsp;'.__('一共').'&nbsp;<b>'.$pager_params['items_count'].'</b>'; ?>
		</div>
		<div class="clear"></div>
		<div class="page_control">		
		<?php for ($i = 1; $i <= $pager_params['total_page']; $i++) { ?>
			<a id="<?php echo $i; ?>" <?php if ($i == $pager_params['page']) echo 'class="curpage" '; ?> onclick="search_form_submit(this.id);"><?php echo $i; ?></a>
		<?php } ?>
		</div>
	</div>
	<input id="hidden_page" name="page" value="<?php echo $page; ?>" />	
</form>
<script>
<!--
var search_form_submit = function(obj){	
	var page = obj;	
	if (page >= 1) {
		$('#hidden_page').val(page);
		$('#search_form').submit();
	}
};
//-->
</script>
<div id="product_list">
<?php foreach ($items as $k=>$i) { ?>
	<div class="item">
		<div class="index"><?php echo $pager_params['begin_index']+$k; ?>.</div>
		<div class="img"><img src="<?php			
			$img_src = strtolower($dir.$i->getName().'.jpg');			
			$default_img_src = $dir.'0.jpg';			
			if (file_exists($root.$img_src))
				echo $img_src;
			else echo $default_img_src;
		?>"/></div>
		<div class="text">
			<a href="/products/view/<?php echo $i->getId(); ?>"><?php echo $i->getName(); ?></a>
			<?php if ($lang == 'ch') { ?>
			<div class="content"><?php echo $i->getContent() ? flCommon::truncate($i->getContent(), 110) : '没有详细信息。'; ?></div>
			<?php } else { ?>
			<div class="content"><?php echo $i->getContentEn() ? flCommon::truncate($i->getContentEn(), 200) : 'no describute.'; ?></div>
			<?php } ?>					
		</div>
		<div class="price"><?php echo $i->getPrice().'&nbsp;RMB'; ?></div>
	</div>
<?php } ?>
</div>